/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	ComponentLight.h
*
*	Description -	Component for lights.
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	01/30/2013	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_COMPONENT_LIGHT_H_
#define _PSX_COMPONENT_LIGHT_H_

#include "PulseSTD.h"
#include "IComponent.h"
#include "Light.h"
#include "ParameterContainer.h"
#include "RenderEntryList.h"

namespace Pulse
{
	class ComponentLight : public IComponent
	{
	public:

		ComponentLight( Actor *pOwner );

		virtual ~ComponentLight( void );

		virtual EErrorCode::Type Initialize( XMLElementPtr pElem );

		virtual const EComponent::Type GetType( void ) const { return EComponent::LIGHT; }

		static const EComponent::Type GetType_Static( void ) { return EComponent::LIGHT; }

		virtual const CHAR * GetName( void ) const { return PSX_String("Light"); }

		const ELight::Type GetLightType( void ) const { return m_light.GetType(); }

		void SetLightType( ELight::Type type );

		const Vector3 * GetColor( void ) const { return m_light.GetColor(); }

		void SetColor( const Vector3 *pColor );

		const FLOAT GetRange( void ) const { return m_light.GetRange(); }

		void SetRange( const FLOAT range );

		const FLOAT GetInnerAngle( void ) const { return m_light.GetInnerAngle(); }

		void SetInnerAngle( const FLOAT innerAngle );

		const FLOAT GetOuterAngle( void ) const { return m_light.GetOuterAngle(); }

		void SetOuterAngle( const FLOAT outerAngle );

		RenderEntryList * GetRenderEntryDrawFront( void ) { return &m_resDrawFront; }

		RenderEntryList * GetRenderEntryDrawBack( void ) { return &m_resDrawBack; }
		
		RenderEntryList * GetRenderEntryDrawQuad( void ) { return &m_resDrawQuad; }

	private:

		// Delegates
		void OnRender( IEvent *pEvent );

		void OnTransform( IEvent *pEvent ); // Not used

	private:

		Light m_light;

		ParameterBinderVector3 *m_pBinderColor;
		ParameterBinderScalar *m_pBinderRange;
		ParameterBinderScalar *m_pBinderSpotInner;
		ParameterBinderScalar *m_pBinderSpotOuter;

		// Cache render entry
		// TODO: We may need multiple versions based on the light type
		//	and its relation to the camera.
		RenderEntryList m_renderEntries;
		RenderEntryList m_resDrawFront;
		RenderEntryList m_resDrawBack;
		RenderEntryList m_resDrawQuad;
	};
}

#endif /* _PSX_COMPONENT_LIGHT_H_ */